import errorEvent from '../../errorMessage'

export default {
    async getDetail(id) {
        try {
            var Sql = `SELECT * FROM project WHERE project_id = '${id}'`;
            var data = await window.DB.get(Sql);
            return data;
        } catch (error) {
            errorEvent(error);
            return false;
        };
    },
    async editDetail(id, p) {
        try {
            var UT = new Date().getTime();
            var Sql = `UPDATE project SET 
            title = '${p.title.replace(/\'/g, "\'\'")}',
            description = '${p.description.replace(/\'/g, "\'\'")}',
            update_time = ${UT}
            WHERE project_id = '${id}'`;
            await window.DB.update(Sql);
            return true;
        } catch (error) {
            errorEvent(error);
            return false;
        };
    },
    async getStatusGrounp(id) {
        try {
            var Sql = `select status, count(status) AS num FROM project_api AS a WHERE project_id = '${id}' AND disable = 0 GROUP BY status`;
            var data = await window.DB.find(Sql);
            return data;
        } catch (error) {
            errorEvent(error);
            return false;
        };
    },


}